Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #182: wrong offset within 1hr of DST start #233

Merged
merged 2 commits into from
Oct 28, 2020

Conversation

bsvetlik
Copy link
Contributor

Solved the Chicken and Egg Problem described in summerTime.js: "we can't get the date, without knowing the timezone, and vice-versa".
In order to eliminate the time zone offset effect the given UTC time is compared to the DST change boundaries converted to UTC.

spencermountain and others added 2 commits September 14, 2020 16:58
Solved to Chicken and Egg Problem described in summerTime.js: "we can't get the date, without knowing the timezone, and vice-versa".
In order to eliminate the time zone offset effect the given UTC time is compared to the DST change boundaries converted to UTC.
@spencermountain spencermountain changed the base branch from master to dev October 28, 2020 15:31
@spencermountain
Copy link
Owner

holy crap!
i would hug you if I could.
gonna merge this into develop and throw a bunch of tests at it - I guess the trick is using Date.UTC()?
That is an extremely clever solution.
WIll play-around with this this afternoon, and check back.
Thank you, so much.

@spencermountain spencermountain merged commit e2b9df9 into spencermountain:dev Oct 28, 2020
@bsvetlik
Copy link
Contributor Author

Hi,
I'm glad I was able to help!
A few days ago I solved the similar problem: change JS Date object to show time in another time zone. I evaluated a number of date-time libraries that support DST changes (moment, luxon, date-fns-tz) but they were amazingly slow (0.5sec for 10,000 conversions). I had to find other solution: given the specific time zone offsets with DST change boundaries received from the server as UTC milliseconds shift the time by corresponding offset. I developed an algorithm that was much faster (15 milliseconds for 10,000 conversions). The spacetime library issue #182 was similar to my problem. The only difference was the DST change boundaries in the specific time zone. After converting them to UTC the Chicken and Egg problem (I liked your description - it was in tune with my thoughts when I worked on conversion algorithm) was solved!
Regards. Boris.

spencermountain added a commit that referenced this pull request Oct 28, 2020
spencermountain added a commit that referenced this pull request Oct 28, 2020
spencermountain added a commit that referenced this pull request Oct 28, 2020
@spencermountain
Copy link
Owner

this works amazingly.

published as 6.8.0
🏅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants